package com.senac.service;

import java.util.List;

import com.senac.dao.DisciplinaDao;
import com.senac.exception.DisciplinaException;
import com.senac.model.Disciplina;

public class DisciplinaService implements DisciplinaServiceLocal {

	private DisciplinaDao dao = new DisciplinaDao();

	@Override
	public List<Disciplina> getDisciplinas() {
		return dao.getDisciplinas();
	}

	@Override
	public Disciplina getDisciplinaById(Integer id) {
		return dao.getDisciplinasById(id);
	}

	@Override
	public boolean save(Disciplina disciplina) throws DisciplinaException {
		
		DisciplinaValidate.validateDisciplina(disciplina);
		
		if (disciplina.getId() <= 0) {
			return insert(disciplina);
		}else{
			return update(disciplina);
		}
	}

	@Override
	public boolean insert(Disciplina disciplina) {
		return dao.save(disciplina);
	}

	@Override
	public boolean update(Disciplina disciplina) {
		return dao.update(disciplina);
	}

	@Override
	public boolean delete(Integer id) {
		return dao.delete(id);
	}
	
	@Override
	public List<Disciplina> getDisciplinasByProfessor(int idProfessor) {
		return dao.getDisciplinasByProfessor(idProfessor);
	}
}
